/*
 This file 'Exception' is part of Firebird Integrated Solution 1.0

 Copyright (c) 2014 Lincong

 Contact:  
 Email: lincong1987@gmail.com

 QQ: 159257119

 See Usage at http://www.jplatformx.com/firebird

 Create date: 2014-06-19 16:14
 */

define(function (require, exports, module) {

	var Model = require("Firebird.Model");

	/**
	 * Firebird.lang.Exception
	 * @class Firebird.lang.Exception
	 */
	Firebird.define("Firebird.lang.Exception", {
		extend: "Firebird.Model",
		config: {
			name: "Exception",
			error: null,
			line: null,
			code: null,
			message: null,
			stack: null
		},
		_init: function () {
			if (this.getError() instanceof Error) {
				var e = this.getError();
				e.name = this.getName() ||  e.name || this.$classname;
				this.setMessage(e.message);
				this.setStack(e.stack);
				firebird.error(e);
			} else {
				var e = new Error();
				e.name = this.getName() || this.$classname;
				e.stack = this.getStack() || e.stack || "unknow stack";
				e.message = this.getMessage() || e.message || "unknow exception message";
				firebird.error(e);
			}

//			$.dialog.error(this.getMessage(), null, {
//				content: "<textarea rows='8' style='width: 400px;'>"
//					+ this.getStack()
//					+ "</textarea>"
//			});

		}
	});

	module.exports = Firebird.lang.Exception;

});